﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace HiLand.Utility.DataBase
{
    public static class DataReaderHelper
    {
        /// <summary>
        /// 判定某个字段在reader中是否存在
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="fieldName"></param>
        /// <returns></returns>
        public static bool IsExistField(IDataReader reader, string fieldName)
        {
            bool isSuccessfule = false;
            fieldName = fieldName.ToLower();
            int fieldCount = reader.FieldCount;
            for (int i = 0; i < fieldCount; i++)
            {
                string currentFieldName = reader.GetName(i).ToLower();
                if (currentFieldName == fieldName)
                {
                    isSuccessfule = true;
                    break;
                }
            }
            return isSuccessfule;
        }
    }
}
